#!/bin/bash

set -e

# Sign chipsec kernel module
echo $(ls ${BUILDROOT}/usr/lib/modules)
echo $(find ${BUILDROOT}/usr/lib/modules/6.13.6-arch1-1/build/scripts -maxdepth 3 -name sign-file) sha256 ${SRCDIR}/mkosi/mkosi.{key,crt} $(find ${BUILDROOT}/usr -name "chipsec.ko")

$(find ${BUILDROOT}/usr/lib/modules/6.13.6-arch1-1/build/scripts -maxdepth 3 -name sign-file) sha256 ${SRCDIR}/mkosi/mkosi.{key,crt} $(find ${BUILDROOT}/usr -name "chipsec.ko")

sbsign --key ${SRCDIR}/mkosi/mkosi.key --cert ${SRCDIR}/mkosi/mkosi.crt ${BUILDROOT}/efi/EFI/Tools/Shell.efi
mv ${BUILDROOT}/efi/EFI/Tools/Shell.efi.signed ${BUILDROOT}/efi/EFI/Tools/Shell.efi

sbsign --key ${SRCDIR}/mkosi/mkosi.key --cert ${SRCDIR}/mkosi/mkosi.crt ${BUILDROOT}/efi/EFI/Tools/Python.efi
mv ${BUILDROOT}/efi/EFI/Tools/Python.efi.signed ${BUILDROOT}/efi/EFI/Tools/Python.efi
